﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Drawing;

namespace DayAtTheRaces
{
    public class Greyhound
    {
        public int StartingPosition; // Where my PictureBox Starts
        public int RacetrackLength; // How long the racetrack is
        public PictureBox MyPictureBox = null; // My PictureBox object
        public int Location = 0; // My Location on the racetrack
        public Random Randomizer; // An instance of Random

        public bool Run()
        {
            // Move forward either 1, 2, 3, or 4 spaces at random
            Randomizer = new Random();
            int distance = Randomizer.Next(3);

            // Update the position of my PictureBox on the form
            Point p = MyPictureBox.Location;
            p.X += distance;
            MyPictureBox.Location = p;
            // Return true if I won the race
            if (p.X == 600)
            {
                MessageBox.Show("Congratulations! The winner is Dog number" + this.MyPictureBox + "!");
                this.TakeStartingPosition();
                return true;
            }
            else
            {
                return false;
            }
        }

        public void TakeStartingPosition()
        {

            Location = 0; // Reset my location to the start line
        }
    }
}
